package com.xiaoda.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;

/**
 * 帖子实体类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Article {

    private int id; // 帖子编号
    private String title; // 帖子标题
    private String content; // 帖子内容
    private User uid; // 发帖人
    private int count; // 浏览量
    private Timestamp createTime; // 创建时间

    /**
     * 获取创建时间
     * @return 返回格式化后的时间
     */
    public String getCreateTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (createTime == null) {
            return "";
        }
        return sdf.format(createTime);
    }
}
